package com.me.test.service;

import com.me.test.domain.User;
import com.me.test.mapper.UserMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ME
 * @date 2021/5/9
 */
@Service
public class UserServiceImpl implements UserService {
    private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper mapper;

    @Override
    public User findById(Long id) {
        if (id == null) {
            return null;
        }
        return mapper.getUserById(id);
    }

    @Override
    public List<User> findAll(User user) {
        return mapper.getUsers(user);
    }

    @Override
    public List<User> findAll2(String name, Integer age) {
        return mapper.getUsers2(name, age);
    }

    @Override
    public int add(User user) {
        return mapper.insert(user);
    }

    @Override
    public int update(User user) {
        return mapper.update(user);
    }

    @Override
    public int del(User user) {
        return mapper.delete(user);
    }

}
